#include "Control/GUIFrameWindow.h"
#include "Control/GUIWindowManager.h"
#include "Control/GUITitlebar.h"
#include "GUISystem.h"
#include "GUIBase.h"

namespace YGUI
{
    const String FrameWindow::WidgetTypeName("FrameWindow");
    const String FrameWindow::TypeName("FrameWindow");
    const String FrameWindow::TitlebarNameSuffix("__auto_titlebar__");

    FrameWindow::FrameWindow(const String &type, const String &name) : 
        Window(type, name)
    {
        m_isFrameEnabled = true;
    }

    FrameWindow::~FrameWindow(void)
    {
    }

    bool FrameWindow::isFrameEnabled(void) const
    {
        return m_isFrameEnabled;
    }

    void FrameWindow::initComponents(void)
    {
        Titlebar* titlebar = getTitlebar();
        if(titlebar)
            titlebar->setText(m_text);
        notifyChildWindowLayout();
    }

    Titlebar* FrameWindow::getTitlebar(void)
    {
        String name = getName() + TitlebarNameSuffix;
        return static_cast<Titlebar*>(WindowManager::getSingleton().getWindow(name));
    }
};